//  合约列表
export  const contractListTask = function () {
    // latestRecordTask  start
    let queue = []; //  缓存改变的队列
    let debug = true; //debug  打印 日志

    const log = {
        print: function (s) {
            if (debug) {
                console.log(s)
            }
        },
    }
    // 数据去重的方法
    function handleArray(data) {
        let flag = {

        }
        /**
         *  exist: 0
            orderPrice: "10262.0"
            orderQuantity: 58175
            orderQuantityShow: "58,175"
            priceD: 10262
         */
        const newArr = [];
        for (let i = 0; i < data.length; i++) {
            const item = data[i];
            const key = item.orderPrice;
            if (!flag[`${key}`] && item.orderQuantity > 0) {
                flag[`${key}`] = true;
                newArr.push(item);
            }
        }
        return newArr;
    }
    // eslint-disable-next-line no-restricted-globals
    self.onmessage = function (e) {
        const data = e.data;
        queue.unshift(data);  //
        //500ms  推送一次
        setInterval(function(){
            postMessage(queue)
            
            queue =[];
        },500)
    }



    // latestRecordTask  end
}

